package com.kaifamiao.operators;

// 逻辑运算符:
// || 逻辑或
//    对于 expression1 || expression2 来说 当 expression1 或 expression2 至少一个为 true 结果就为 true
// && 逻辑与
//    对于 expression1 && expression2 来说 当 expression1 与 expression2 都为 true 结果才为 true
// !  逻辑非
//    !expression
public class Horse {
    public static void main(String[] args) {
        boolean first = true, second = true,third = false, fourth = false;
        // 逻辑或
        System.out.println( first || third );
        System.out.println( third || fourth );
        System.out.println( "- - - - - - - - - - -" );
        // 逻辑与
        System.out.println( first && second );
        System.out.println( first && third );
        System.out.println( "- - - - - - - - - - -" );
        // 逻辑非(逻辑取反)
        System.out.println( !first );
        System.out.println( !third );

        System.out.println( "~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~" );

        // 使用 & 和 | 可以操作 逻辑值
        System.out.println( first & second );
        System.out.println( first & third );
        System.out.println( first | second );
        System.out.println( first | third );
    }
}
